<?php
	//include_once('verifica.php');
	include_once('config/class.pdo.php');
	
	//print_r($_POST[id]);
	if(isset($_POST['id'])) {
		$pdo = new DB;	
		$pdo-> conexao();
		
		$Query = 'SELECT 
					empregador,
					cnpj,
					ie,
					celular,
					email,
					razaoSolical,
					nomeFantasia,
					date_format(dataCadastro, "%d/%m/%Y %T") as dataCadastro,
					idEntidade
				  FROM entidade 
		WHERE idEntidade = '.$_POST['id'].'';
		$result = $pdo->oneReg($Query);				
		//print_r($result);
	} 			
?>
<!doctype html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<link rel="stylesheet" href="css/jquery-ui.css" />
		<link rel="stylesheet" href="css/style.css" />
		<script type="text/javascript" src="js/jquery-1.9.1.js" ></script>
		<script type="text/javascript" src="js/jquery-ui.js" ></script>	
		<script type="text/javascript" src="js/jquery.maskedinput.js" ></script>		
		<script type="text/javascript" src="js/jquery.validate.js" ></script>
		<script type="text/javascript" src="js/jsCadEmpregador.js"></script>	
		<script type="text/javascript" src="js/funcoes.js"></script>			
	</head>	
	<body style="font-size:10px;">
		<form name="frmEmpregador" id="frmEmpregador" method="POST">
			<div id="divEmpregador" class="divEmpregador">
				<fieldset class="backFieldset">
					<legend> <b> Cadastro de Empregador </b> </legend>
					<table class="table">
						<?php 
							if(isset($_POST['id'])) {
								echo '<tr>';
								echo '<td> Código: </td>';
								echo '<td colspan=0> <input type="text" name="ce_id" id="ce_id" value="'.$result['idEntidade'].'" readonly /> </td>';
								echo '<td> Cadastro: </td>';
								echo '<td colspan=0> <input type="text" name="ce_dataCadastro" id="ce_dataCadastro" value="'.$result['dataCadastro'].'" readonly /> </td>';
								echo '</tr>';
							}
						?>
						<tr>
							<td> Razão Social: </td>
							<td colspan=3> <input type="text" name="ce_razao" id="ce_razao" class="input-xxlarge" title="Campo RAZÃO SOCIAL deve ser preenchido." value="<?php echo utf8_encode(@$result['razaoSolical']); ?>" required /> </td>
						</tr>
						<tr>
							<td> Nome Fantasia: </td>
							<td colspan=3> <input type="text" name="ce_fantasia" id="ce_fantasia" class="input-xxlarge" title="Campo NOME FANTASIA deve ser preenchido." value="<?php echo utf8_encode(@$result['nomeFantasia']); ?>" required /> </td>
						</tr>
						<tr>
							<td> CNPJ: </td>
							<td colspan=0> <input type="text" name="ce_cnpj" id="ce_cnpj" onBlur="validarCNPJ(ce_cnpj);" title="Campo CNPJ deve ser preenchido." value="<?php echo @$result['cnpj']; ?>" size="100" /> </td>
							<td> IE: </td>
							<td colspan=0> <input type="text" name="ce_ie" id="ce_ie" title="Campo IE deve ser preenchido." value="<?php echo @$result['ie']; ?>" size="100" /> </td>
						</tr>
						<tr>
							<td> Telefone: </td>
							<td colspan=0> <input type="text" name="ce_telefone" id="ce_telefone" title="Campo CELULAR deve ser preenchido." value="<?php echo @$result['celular']; ?>" size="13" /> </td>
							<td> E-Mail: </td>
							<td colspan=0> <input type="email" name="ce_email" id="ce_email" title="E-MAIL deve ser preenchido corretamente." value="<?php echo @$result['email']; ?>" size="13" /> </td>
						</tr>
						<tr>
						<?php
							if(isset($_POST['id'])) {
								echo '<td colspan=4 align="right"> <button type="button" name="endereco" id="endereco" onclick="enderecos()" class="btn btn-info" > <i class="icon-plus"></i> Endereços </button> </td>';
							} else {
								echo '<td colspan=4> <input type="checkbox" name="cadastrarEndereco" id="cadastrarEndereco" value="1"> Na sequência deseja cadastrar o(s) endereço(s) do Empregador? </td>';
							}
						?>
						</tr>
					</table>
				</fieldset>
			</div>
			<?php
				echo '<table>';
					echo '<tr>';
						if(isset($_POST['id'])) {
							echo '<td> <button type="submit" name="atualizar" class="btn btn-success"> <i class="icon-refresh"></i> Atualizar </button>'; 
							echo '    <button type="button" name="cancelar" onclick="apagaForm()" class="btn btn-danger" > <i class="icon-ban-circle"></i> Cancelar </button>';
							echo '    <button type="button" name="voltar" id="voltar" onclick="loadPage(9);" class="btn btn-primary" > <i class="icon-arrow-left"></i> Voltar </button> <input type="hidden" id="controle" value="atualizar"> </td>';
						} else {
							echo '<td> <button type="submit" name="gravar" class="btn btn-success"> <i class="icon-ok"></i> Gravar </button>'; 
							echo '    <button type="button" name="cancelar" onclick="apagaForm()" class="btn btn-danger" > <i class="icon-ban-circle"></i> Cancelar </button>';
							echo '    <button type="button" name="sair" id="sair" onclick="loadPage(1);" class="btn btn-primary" > <i class="icon-home"></i> Sair </button> <input type="hidden" id="controle" value="gravar"> </td>';
						}
					echo '</tr>';
				echo '</table>';
			?>
		</form>
		<div id="retornoEmpregador"> </div>
		<div class="container">
				<h4>Favor preencha os campos abaixo citados:</h4>
				<ol>					
				</ol>
		</div>
	</body>
</html>